package com.icangya.DAO.impl;

import com.icangya.DAO.IUserPointsRecordDAO;
import com.icangya.Utils.SQLUtilt;
import com.icangya.domain.UserPointsRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

import static com.icangya.Value.FootBall.FOOT_PAGE_ROW;


@Repository
public class UserPointsRecordDAOImpl extends  BaseDAO<UserPointsRecord> implements IUserPointsRecordDAO {

    Logger logger = LoggerFactory.getLogger(this.getClass());


    @Override
    public List<Object> getPointsRecordByUserId(Long userId, Integer pageNum) {
        String hql="FROM UserPointsRecord er where er.userId='"+userId+"' order by er.pointsTime desc";
        String count = "SELECT COUNT(er) " + hql;
        Long total = (Long) getHibernateTemplate().find(count).get(0);
        return SQLUtilt.getIstance().doPage(getHibernateTemplate(), hql, total, pageNum, FOOT_PAGE_ROW);
    }
}
